using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace ERPStore.QuoteCart.Repositories.Mapping
{
	public class QuoteCartItemMap : EntityTypeConfiguration<Datas.QuoteCartItem>
	{
		public QuoteCartItemMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

            this.Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);

			// Properties
			this.Property(t => t.RevisionId)
				.IsRequired()
				.IsFixedLength()
                .IsConcurrencyToken()
                .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed)
				.HasMaxLength(8);

			this.HasRequired(t => t.QuoteCart)
				.WithMany(t => t.Items)
				.HasForeignKey(d => d.QuoteCartId);
			
			// Table & Column Mappings
			this.ToTable("QuoteCartItem");
		}
	}
}

